<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>供应商不良返品</title>
<jsp:include page="./common.jsp"></jsp:include>
<script type="text/javascript">
$(function () {
	//入库
	var rkYear = rkYearNum();
	//返品
	var returnYear = returnYearNum();
	var rkArr = new Array()
	
	if(rkYear.length > 0 && rkYear[0] != null){
		rkArr.push(rkYear[0].num1)
		rkArr.push(rkYear[0].num2)
		rkArr.push(rkYear[0].num3)
		rkArr.push(rkYear[0].num4)
		rkArr.push(rkYear[0].num5)
		rkArr.push(rkYear[0].num6)
		rkArr.push(rkYear[0].num7)
		rkArr.push(rkYear[0].num8)
		rkArr.push(rkYear[0].num9)
		rkArr.push(rkYear[0].num10)
		rkArr.push(rkYear[0].num11)
		rkArr.push(rkYear[0].num12)
	}else{
		rkArr = [0,0,0,0,0,0,0,0,0,0,0,0]
	}
	var returnArr = new Array()
	if(returnYear.length > 0 && returnYear[0] != null){
		returnArr.push(returnYear[0].num1)
		returnArr.push(returnYear[0].num2)
		returnArr.push(returnYear[0].num3)
		returnArr.push(returnYear[0].num4)
		returnArr.push(returnYear[0].num5)
		returnArr.push(returnYear[0].num6)
		returnArr.push(returnYear[0].num7)
		returnArr.push(returnYear[0].num8)
		returnArr.push(returnYear[0].num9)
		returnArr.push(returnYear[0].num10)
		returnArr.push(returnYear[0].num11)
		returnArr.push(returnYear[0].num12)
	}else{
		returnArr = [0,0,0,0,0,0,0,0,0,0,0,0]
	}
	var rkhe = 0;
	for (var i = 0; i < rkArr.length; i++) {
		document.all("tb_departments").rows[1].cells[i+1].innerText = rkArr[i];
		rkhe += rkArr[i]
	}
	document.all("tb_departments").rows[1].cells[rkArr.length+1].innerText = rkhe;
	
	var rehe = 0;
	for (var i = 0; i < returnArr.length; i++) {
		document.all("tb_departments").rows[2].cells[i+1].innerText = returnArr[i];
		rehe += returnArr[i];
	}
	document.all("tb_departments").rows[2].cells[returnArr.length+1].innerText = rehe;
	
var chart = Highcharts.chart('container', {
    chart: {
        type: 'spline'
    },
    title: {
        text: '不良返品'
    },
    xAxis: {
    	 categories: ['一月', '二月', '三月', '四月', '五月', '六月',
                      '七月', '八月', '九月', '十月', '十一月', '十二月']
    },
    yAxis: {
        title: {
            text: '百分比'
        },
        labels: {
            formatter: function () {
                return this.value + '%';
            }
        }
    },
    tooltip: {
        crosshairs: true,
        shared: true
    },
    plotOptions: {
        spline: {
            marker: {
                radius: 4,
                lineColor: '#666666',
                lineWidth: 1
            }
        }
    },
    series: [{
        name: '入库数量',
        marker: {
            symbol: 'square'
        },
        data: rkArr
    }, {
        name: 'IN-LINS返品（PPM）',
        marker: {
            symbol: 'diamond'
        },
        data: returnArr
    }]
});
});


//加载所有的入库
function rkYearNum() {
	var data = new Array()
    $.ajax({
    	url:'${pageContext.request.contextPath }/reportD/rkYearNum.do',
    	type:"POST",
    	dataType:'json',
    	async: false,
    	success:function (result) { 
    		data = result 
    	}
    });
    return data
}
//加载所有的返品
function returnYearNum() {
	var data = new Array()
    $.ajax({
    	url:'${pageContext.request.contextPath }/reportD/returnYearNum.do',
    	type:"POST",
    	dataType:'json',
    	async: false,
    	success:function (result) { 
    		data = result 
    	}
    });
	return data
}
</script>
</head>
<body>
        <table id="tb_departments" class="table table-bordered">
        	<tr  align="center">
        		<td>区分</td>
        		<td>1月</td>
        		<td>2月</td>
        		<td>3月</td>
        		<td>4月</td>
        		<td>5月</td>
        		<td>6月</td>
        		<td>7月</td>
        		<td>8月</td>
        		<td>9月</td>
        		<td>10月</td>
        		<td>11月</td>
        		<td>12月</td>
        		<td>合计</td>
        	</tr>
        	<tr>
        		<td>入库数量</td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        	</tr>
        	<tr>
        		<td>IN-LINS返品（PPM）</td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        		<td></td>
        	</tr>
        </table>
        <div id="container" style="min-width:100px;height:400px"></div>
        
</body>
</html>